package utils

import "github.com/Masterminds/semver/v3"

type (
	PackageJson struct {
		Name                 string            `json:"name"`
		Version              string            `json:"version"`
		Private              bool              `json:"private"`
		Scripts              map[string]string `json:"scripts"`
		Dependencies         map[string]string `json:"dependencies"`
		DevDependencies      map[string]string `json:"devDependencies"`
		PeerDependencies     map[string]string `json:"peerDependencies"`
		BundledDependencies  map[string]string `json:"bundledDependencies"`
		OptionalDependencies map[string]string `json:"optionalDependencies"`
	}
	DependenciesInfo struct {
		ID       string `json:"_id"`
		Rev      string `json:"_rev"`
		Name     string `json:"name"`
		DistTags struct {
			Beta   string `json:"beta"`
			Latest string `json:"latest"`
		} `json:"dist-tags"`
		Time         map[string]string              `json:"time"`
		Versions     map[string]DependenciesVersion `json:"versions"`
		ErrorMessage string                         `json:"error"`
	}
	DependenciesVersion struct {
		Name    string `json:"name"`
		Version string `json:"version"`
		ID      string `json:"_id"`
		Dist    struct {
			Shasum       string `json:"shasum"`
			Tarball      string `json:"tarball"`
			FileCount    int    `json:"fileCount"`
			Integrity    string `json:"integrity"`
			UnpackedSize int    `json:"unpackedSize"`
			NpmSignature string `json:"npm-signature"`
		} `json:"dist"`
		NpmVersion      string            `json:"_npmVersion"`
		NodeVersion     string            `json:"_nodeVersion"`
		Dependencies    map[string]string `json:"dependencies"`
		DevDependencies map[string]string `json:"devDependencies"`
	}

	DependenciesOneVersion struct {
		Name    string `json:"name"`
		Version string `json:"version"`
		Dist    struct {
			Shasum    string `json:"shasum"`
			Tarball   string `json:"tarball"`
			Integrity string `json:"integrity"`
			Size      int    `json:"size"`
		} `json:"dist"`
		Dependencies    map[string]string `json:"dependencies"`
		DevDependencies map[string]string `json:"devDependencies"`
		ErrorMessage    string            `json:"error"`
	}

	NPMViewInfo struct {
		ID              string `json:"_id"`
		Name            string `json:"name"`
		Version         string `json:"version"`
		DevDependencies struct {
			Chai   string `json:"chai"`
			Eslint string `json:"eslint"`
			Mocha  string `json:"mocha"`
		} `json:"devDependencies"`
		NodeVersion string `json:"_nodeVersion"`
		NpmVersion  string `json:"_npmVersion"`
		Dist        struct {
			Integrity    string `json:"integrity"`
			Shasum       string `json:"shasum"`
			Tarball      string `json:"tarball"`
			FileCount    int    `json:"fileCount"`
			UnpackedSize int    `json:"unpackedSize"`
			Signatures   []struct {
				Keyid string `json:"keyid"`
				Sig   string `json:"sig"`
			} `json:"signatures"`
			Size int `json:"size"`
		} `json:"dist"`
	}

	Config struct {
		Registry              string `yaml:"registry"`
		UserAgent             string `yaml:"userAgent"`
		MaxConcurrentRequests int64  `yaml:"maxConcurrentRequests"`
		Versions              struct {
			OnlyRelease            bool     `yaml:"onlyRelease"`
			ExcludeVersionKeywords []string `yaml:"excludeVersionKeywords"`
		} `yaml:"versions"`
		Nexus struct {
			Host       string `yaml:"host"`
			Repository string `yaml:"repository"`
			Username   string `yaml:"username"`
			Password   string `yaml:"password"`
			Threads    int64  `yaml:"threads"`
		} `yaml:"nexus"`
	}
	MyVersions struct {
		version *semver.Version
		Tarball string
	}
)
